using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using lucienneCRMApp.Models;

namespace lucienneCRMApp.Controllers
{
    public class GuestBookEntriesController : Controller
    {
        private lucienneCRMAppContext context = new lucienneCRMAppContext();

        //
        // GET: /GuestBookEntries/

        public ViewResult Index()
        {
            return View(context.GuestBookEntries.ToList());
        }

        public ViewResult IndexClient()
        {
            return View(context.GuestBookEntries.ToList());
        }

        //
        // GET: /GuestBookEntries/Details/5

        public ViewResult Details(int id)
        {
            GuestBookEntry guestbookentry = context.GuestBookEntries.Single(x => x.EntryId == id);
            return View(guestbookentry);
        }

        //
        // GET: /GuestBookEntries/Create

        public ActionResult Create()
        {
            return View(new GuestBookEntry());
        }

        //
        // POST: /GuestBookEntries/Create

        [HttpPost]
        public ActionResult Create(GuestBookEntry guestbookentry)
        {
            if (ModelState.IsValid)
            {
                context.GuestBookEntries.Add(guestbookentry);
                context.SaveChanges();
                //return RedirectToAction("Index");  
             
               ViewBag.Message = "Thanks for sending a review";
                return RedirectToAction("Client", "People");
           
            }

            return View(guestbookentry);
        }

        //
        // GET: /GuestBookEntries/Edit/5

        public ActionResult Edit(int id)
        {
            GuestBookEntry guestbookentry = context.GuestBookEntries.Single(x => x.EntryId == id);
            return View(guestbookentry);
        }

        //
        // POST: /GuestBookEntries/Edit/5

        [HttpPost]
        public ActionResult Edit(GuestBookEntry guestbookentry)
        {
            if (ModelState.IsValid)
            {
                context.Entry(guestbookentry).State = EntityState.Modified;
                context.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(guestbookentry);
        }

        //
        // GET: /GuestBookEntries/Delete/5

        public ActionResult Delete(int id)
        {
            GuestBookEntry guestbookentry = context.GuestBookEntries.Single(x => x.EntryId == id);
            return View(guestbookentry);
        }

        //
        // POST: /GuestBookEntries/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            GuestBookEntry guestbookentry = context.GuestBookEntries.Single(x => x.EntryId == id);
            context.GuestBookEntries.Remove(guestbookentry);
            context.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                context.Dispose();
            }
            base.Dispose(disposing);
        }

       
    }
}